Grokking Microservices Design Patterns
Rate this course
Ask Author
Contribute
Back to course home

0% completed

Vote For New Content
Introduction
Who Should Take This Course?
The Course at a Glance
Strangler Fig Pattern
Introduction
The Problem: Legacy Systems
The Strangler Pattern: A Solution
The Architecture of the Strangler Pattern
Strangler Pattern: A Detailed Example
Key Insights and Implications
Introduction to the API Gateway Pattern
Advantages of API Gateway Pattern
API Gateway Pattern: An Example
Performance Implications
System Design Example
Introduction to BFF
The Problem: Traditional Backend Models
The Architecture of the BFF Pattern
BFF Pattern: An Example
Performance Implications
System Design Examples
What is Service Discovery Pattern?
The Problem: Service Coordination in Distributed Systems
Service Discovery Pattern: A Solution
The Architecture of the Service Discovery Pattern
The Inner Workings of the Service Discovery Pattern
Service Discovery Pattern: An Example
Performance Implications and Special Considerations
System Design Examples
Security Considerations
Introduction
The Problem: The Struggles of Distributed Systems and Service Failures
The Circuit Breaker Pattern: An Effective Shield Against Cascading Failures
Circuit Breaker Pattern: An Example
Performance Implications and Special Considerations
System Design Examples
Summary
Introduction
The Problem: Failure Propagation in Distributed Systems
The Bulkhead Pattern: A Solution
The Architecture
The Inner Workings
Bulkhead Pattern: A Example
Performance Implications and Special Considerations
System Design Examples
Conclusion
Introduction
The Retry Pattern: A Solution to Unreliable External Resources
The Architecture of the Retry Pattern
Retry Pattern: An Example
Performance Implications
Use Cases and System Design Examples
Conclusion
Introduction to the Sidecar Pattern
The Problem: Monolithic Application Management
A Solution to the Monolithic Mayhem
The Architecture of the Sidecar Pattern
Sidecar Pattern: Bringing Theory to Practice with an Example
Performance Implications
System Design Examples: Bringing the Sidecar Pattern to Life
Introduction to Saga Pattern
The Problem: Traditional Transaction Models
The Saga Pattern: A Solution
The Architecture of the Saga Pattern
The Inner Workings of the Saga Pattern
Saga Pattern: A Example
Performance Implications
System Design Examples
Conclusion
Introduction
The Problem: Managing Complex Interactions in Distributed Systems
Event-Driven Architecture: A Promising Solution
The Architecture of the Event-Driven Architecture Pattern
The Inner Workings of the Event-Driven Architecture Pattern
Event-Driven Architecture Pattern: An Example
Performance Implications and Special Considerations
Use Cases and System Design Examples
Conclusion
Introduction
The Problem: Traditional CRUD Operations
CQRS Pattern: A Solution
The Architecture of the CQRS Pattern
The Inner Workings of the CQRS Pattern
CQRS Pattern: An Example
Issues, Special Considerations, and Performance Implications
System Design Examples
Introduction
The Problem: Configuration Management in a Microservices Architecture
The Solution: Configuration Externalization Pattern
Unveiling the Architecture: How Does Configuration Externalization Work?
Delving into Code: An Example
Considerations and Implications
Use Cases and Real-world Examples
Conclusion
Embrace the Future of Software Architecture
The Architecture of the Strangler Pattern

A Layered Approach

The Strangler Pattern adopts a layered approach in its architecture. Imagine peeling an onion layer by layer, with each layer representing a part of the legacy system being replaced by the new system.

Facade Interface: The Gatekeeper

The central component in the Strangler Pattern's architecture is the Facade Interface. This is the gatekeeper that decides whether a request should be handled by the new system or the legacy system. Let's think of it as a traffic controller at an intersection, guiding cars (or in our case, requests) down the correct road.

When a request arrives, the Facade Interface checks if the requested functionality has been migrated to the new system. If it has, the request is directed to the new system. If not, the request continues to be handled by the legacy system.

Phased Migration: One Step at a Time

The migration from the legacy system to the new system doesn't happen all at once. It happens in a step-by-step process.

The migration starts by identifying a piece of functionality that can be easily isolated and redirected from the legacy system to the new system. This piece of functionality is then rebuilt in the new system.

Once it's fully tested and ready to go live, the Facade Interface starts redirecting requests for this functionality to the new system, while still sending the remaining requests to the legacy system. This gradual shift of responsibilities from the old system to the new one forms the crux of the Strangler Pattern.

Strangler Pattern - Step by step migration
Strangler Pattern - Step by step migration

Strangler Fig: An Example: Imagine we have an old system for user management and we want to replace the "getUserDetails" function with a new service. We might use a simple router to decide which service to use:

class UserServiceRouter: def getUserDetails(self, userID): if self.useNewService(userID): return NewUserService().getUserDetails(userID) else: return OldUserService().getUserDetails(userID) def useNewService(self, userID): # Logic to decide which service to use. # For simplicity, let's say we use the new service for even userIDs. return userID % 2 == 0 class OldUserService: def getUserDetails(self, userID): # Old way of fetching user details pass class NewUserService: def getUserDetails(self, userID): # New, improved way of fetching user details pass

As we become confident in NewUserService, we can adjust useNewService logic to send more traffic to the new service until OldUserService is no longer used.

The Strangler Pattern: A Solution
Strangler Pattern: A Detailed Example
Mark as Completed

On this page

A Layered Approach

Facade Interface: The Gatekeeper

Phased Migration: One Step at a Time